load("@rules_java//java:defs.bzl", "java_library")

package(
    default_applicable_licenses = [
        "//:license",
    ],
    default_visibility = [
        "//checker:__pkg__",
        "//publish:__pkg__",
    ],
)

# keep sorted
CHECKER_SOURCES = [
    "CelCheckerLegacyImpl.java",
    "ProtoTypeMaskTypeProvider.java",
]

# keep sorted
CHECKER_BUILDER_SOURCES = [
    "CelChecker.java",
    "CelCheckerBuilder.java",
    "CelCheckerLibrary.java",
]

# keep sorted
CHECKER_LEGACY_ENV_SOURCES = [
    "DescriptorTypeProvider.java",
    "Env.java",
    "ExprChecker.java",
    "ExprVisitor.java",
    "InferenceContext.java",
    "TypeFormatter.java",
    "TypeProvider.java",
    "Types.java",
]

java_library(
    name = "type_provider_legacy",
    srcs = [
        "DescriptorTypeProvider.java",
        "TypeProvider.java",
        "Types.java",
    ],
    tags = [
    ],
    deps = [
        "//:auto_value",
        "//common/annotations",
        "//common/internal:file_descriptor_converter",
        "//common/types",
        "//common/types:cel_proto_types",
        "//common/types:type_providers",
        "@cel_spec//proto/cel/expr:checked_java_proto",
        "@maven//:com_google_errorprone_error_prone_annotations",
        "@maven//:com_google_guava_guava",
        "@maven//:com_google_protobuf_protobuf_java",
        "@maven//:org_jspecify_jspecify",
    ],
)

java_library(
    name = "checker",
    srcs = CHECKER_SOURCES,
    tags = [
    ],
    deps = [
        ":cel_ident_decl",
        ":checker_builder",
        ":checker_legacy_environment",
        ":proto_type_mask",
        ":standard_decl",
        ":type_provider_legacy_impl",
        "//:auto_value",
        "//common:cel_ast",
        "//common:cel_descriptors",
        "//common:cel_source",
        "//common:compiler_common",
        "//common:container",
        "//common:options",
        "//common:source_location",
        "//common/annotations",
        "//common/ast:expr_converter",
        "//common/internal:env_visitor",
        "//common/internal:errors",
        "//common/types",
        "//common/types:cel_proto_types",
        "//common/types:message_type_provider",
        "//common/types:type_providers",
        "@cel_spec//proto/cel/expr:checked_java_proto",
        "@maven//:com_google_errorprone_error_prone_annotations",
        "@maven//:com_google_guava_guava",
        "@maven//:com_google_protobuf_protobuf_java",
    ],
)

java_library(
    name = "checker_builder",
    srcs = CHECKER_BUILDER_SOURCES,
    tags = [
    ],
    deps = [
        ":checker_legacy_environment",
        ":proto_type_mask",
        ":standard_decl",
        "//common:cel_ast",
        "//common:compiler_common",
        "//common:container",
        "//common:options",
        "//common/types:type_providers",
        "@cel_spec//proto/cel/expr:checked_java_proto",
        "@maven//:com_google_errorprone_error_prone_annotations",
        "@maven//:com_google_protobuf_protobuf_java",
    ],
)

java_library(
    name = "proto_type_mask",
    srcs = ["ProtoTypeMask.java"],
    tags = [
    ],
    deps = [
        "//:auto_value",
        "@maven//:com_google_errorprone_error_prone_annotations",
        "@maven//:com_google_guava_guava",
        "@maven//:com_google_protobuf_protobuf_java",
    ],
)

java_library(
    name = "cel_ident_decl",
    srcs = [
        "CelIdentDecl.java",
    ],
    tags = [
    ],
    deps = [
        "//:auto_value",
        "//common/annotations",
        "//common/ast",
        "//common/ast:expr_converter",
        "//common/types:cel_proto_types",
        "//common/types:type_providers",
        "@cel_spec//proto/cel/expr:checked_java_proto",
        "@maven//:com_google_errorprone_error_prone_annotations",
        "@maven//:com_google_guava_guava",
    ],
)

java_library(
    name = "type_provider_legacy_impl",
    srcs = ["TypeProviderLegacyImpl.java"],
    tags = [
    ],
    deps = [
        ":checker_legacy_environment",
        "//:auto_value",
        "//common/annotations",
        "//common/types",
        "//common/types:cel_proto_types",
        "//common/types:type_providers",
        "@cel_spec//proto/cel/expr:checked_java_proto",
        "@maven//:com_google_errorprone_error_prone_annotations",
        "@maven//:com_google_guava_guava",
        "@maven//:org_jspecify_jspecify",
    ],
)

java_library(
    name = "checker_legacy_environment",
    srcs = CHECKER_LEGACY_ENV_SOURCES,
    tags = [
    ],
    deps = [
        ":cel_ident_decl",
        ":standard_decl",
        "//:auto_value",
        "//common:cel_ast",
        "//common:compiler_common",
        "//common:container",
        "//common:options",
        "//common:proto_ast",
        "//common/annotations",
        "//common/ast",
        "//common/ast:expr_converter",
        "//common/internal:errors",
        "//common/internal:file_descriptor_converter",
        "//common/types",
        "//common/types:cel_proto_types",
        "//common/types:cel_types",
        "//common/types:type_providers",
        "//parser:macro",
        "//parser:operator",
        "@cel_spec//proto/cel/expr:checked_java_proto",
        "@cel_spec//proto/cel/expr:syntax_java_proto",
        "@maven//:com_google_errorprone_error_prone_annotations",
        "@maven//:com_google_guava_guava",
        "@maven//:com_google_protobuf_protobuf_java",
        "@maven//:org_jspecify_jspecify",
    ],
)

java_library(
    name = "type_inferencer",
    srcs = ["TypeInferencer.java"],
    tags = [
    ],
    deps = [
        "//:auto_value",
        "//common/types",
        "//common/types:type_providers",
        "@maven//:com_google_errorprone_error_prone_annotations",
        "@maven//:com_google_guava_guava",
    ],
)

java_library(
    name = "proto_expr_visitor",
    srcs = [
        "CelProtoExprVisitor.java",
    ],
    tags = [
    ],
    deps = [
        ":checker_legacy_environment",
        "//common:cel_ast",
        "//common:proto_ast",
    ],
)

java_library(
    name = "standard_decl",
    srcs = [
        "CelStandardDeclarations.java",
    ],
    tags = [
    ],
    deps = [
        ":cel_ident_decl",
        "//common:compiler_common",
        "//common/types",
        "//common/types:cel_types",
        "//common/types:type_providers",
        "//parser:operator",
        "@maven//:com_google_errorprone_error_prone_annotations",
        "@maven//:com_google_guava_guava",
    ],
)
